<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // let a = new Promise((resolve,reject)=>{
    //     reject("haha")
    // })

    // a.then(()=>{},()=>{})       // 未报错，说明被捕获到了
    // a.finally(()=>{})           // Uncaught (in promise) haha        只有then和catch可以捕获错误


    /* try-catch无法捕获promise的reject，reject会异步抛出，也就需要异步捕获 */
    // try {
    //     new Promise((resolve, reject) => {
    //         reject("haha")
    //     })
    // } catch (error) {

    // }


    var b = new Promise((resolve, reject) => resolve(123))

    let result = b.then(3,5).then((value) => console.log(value),()=>{})

    setTimeout(() => {
        console.log(result);
    }, 300);

</script>

</html>